#pragma once
#include <unordered_map>
#include "ConcreteFlyweight.h"

class FlyweightFactory
{
public:
    std::shared_ptr<IFlyweight> GetFlyweight(const std::string& key)
    {
        auto it = _mapFlyweights.find(key);
        if (it != _mapFlyweights.end())
            return it->second;

        auto fw = std::make_shared<ConcreateFlyweight>(key);
        _mapFlyweights[key] = fw;
        return fw;
    }
private:
	std::unordered_map<std::string, std::shared_ptr<IFlyweight>> _mapFlyweights;
};